<style>
.btn.btn-success-o.active{
    background: #00c568;
    color: #fff;
}
</style>
<div class='fui-page fui-page-current'>
	<div class='fui-content'>
			<div style="padding:0 0.5rem;">
			<div style="background:#fff;padding-bottom:1rem">
			<div ng-if="!pagedata.aiset.id" class='fui-cell-group-o' style="margin:0.5rem 1rem;padding-top:0.5rem;">
				<div class='fui-cell-title c bold' style="padding-bottom:0.3rem">{{pagedata.cang.title}}</div>
				<div class='fui-cell-title c' style="color:#999;font-size:0.6rem;padding:0">(挂卖机器人设置)</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-label big bold' style='width:auto;'>预约期数</div>
				</div>
				<div style="padding:0 0.5rem;font-size:0.55rem;margin-top:-0.3rem">
						当前可预约：{{pagedata.yaonum || 0}}期
				</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-info'>
						<input type='text' class='fui-input' style="padding:0.3rem;border-radius:0.3rem;width:100%;background:#f2f2f2" placeholder="要预约的期数" ng-model="pagedata.aiset.yaonum" ng-change="pagedata.upjifen2()">
					</div>
				</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-label big bold' style='width:auto;'>挂卖茶豆</div>
				</div>
				<div style="padding:0 0.5rem;font-size:0.55rem;margin-top:-0.3rem">
						您当前剩余茶豆：{{pagedata.member.credit4 || 0}}个，剩余积分{{pagedata.member.credit1 || 0}}个；
						茶豆可挂卖最大额度：{{pagedata.nowitem.jian_jinmax}}个，最小额度{{pagedata.cang.jian_jinmin || 0}}个
				</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-label' style='width:auto;margin-right:0.5rem'>每期挂卖数量</div>
					<div class='fui-cellone-info'>
						<input type='text' class='fui-input' style="padding:0.3rem;border-radius:0.3rem;width:100%;background:#f2f2f2" placeholder="要挂卖茶豆额度" ng-model="pagedata.aiset.onefee" ng-change="pagedata.upjifen2()">
					</div>
				</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-label' style='width:auto;margin-right:0.5rem'>每期递增数量</div>
					<div class='fui-cellone-info'>
						<input type='text' class='fui-input' style="padding:0.3rem;border-radius:0.3rem;width:100%;background:#f2f2f2" placeholder="要挂卖茶豆额度" ng-model="pagedata.aiset.addfee" ng-change="pagedata.upjifen2()">
					</div>
				</div>
			</div>
			<div ng-if="pagedata.aiset.id" class='fui-cell-group-o' style="margin:0.5rem 1rem;padding-top:0.5rem;">
				<div class='fui-cell-title c bold' style="padding-bottom:0.3rem">{{pagedata.cang.title}}</div>
				<div class='fui-cell-title c' style="color:#999;font-size:0.6rem;padding:0">(挂卖机器人：<span class="red">{{pagedata.aiset.status==1?'启用中':'停止中'}}</span>)</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-label' style='width:auto;margin-right:0.5rem'>选择加倍包</div>
					<div class='fui-cellone-info'>
						{{pagedata.aiset.baobei}}倍，{{pagedata.aiset.baojifen}}个积分
					</div>
				</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-label' style='width:auto;margin-right:0.5rem'>预约期数</div>
					<div class='fui-cellone-info'>
						{{pagedata.aiset.yaonum}}期
					</div>
				</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-label' style='width:auto;margin-right:0.5rem'>每期挂卖数量</div>
					<div class='fui-cellone-info'>
						{{pagedata.aiset.onefee}}个
					</div>
				</div>
				<div class='fui-cellone'>
					<div class='fui-cellone-label' style='width:auto;margin-right:0.5rem'>每期递增数量</div>
					<div class='fui-cellone-info'>
						{{pagedata.aiset.addfee}}个
					</div>
				</div>
			</div>
			<div class="weui_btn_area" style="margin:1rem 2rem;">
				<div ng-if="!pagedata.aiset.id" class="c" style="font-size:0.6rem;margin-top:-0.3rem;color:red">
						需茶豆：{{pagedata.aiset.payfee || 0}}个，需积分{{pagedata.aiset.payjifen || 0}}个						
				</div>
				<div ng-if="pagedata.aiset.id" class="c" style="font-size:0.6rem;margin-top:-0.3rem;color:red">
						消耗茶豆：{{pagedata.aiset.payfee || 0}}个，消耗积分{{pagedata.aiset.payjifen || 0}}个						
				</div>
				<a ng-if="!pagedata.aiset.id" class='weui_btn weui_btn_primary' style="border-radius:1rem;background-color:#18bc9c;" ng-click="pagedata.topost();">创建机器人</a>
				<a ng-if="pagedata.aiset.id && pagedata.aiset.status==0" class='weui_btn weui_btn_primary' style="border-radius:1rem;background-color:#18bc9c;" ng-click="post(pagedata.aiset,'/aiset/setstatus/status=1&id='+pagedata.aiset.id)">启动机器人</a>
				<a ng-if="pagedata.aiset.id && pagedata.aiset.status==1" class='weui_btn weui_btn_primary' style="border-radius:1rem;background-color:#18bc9c;" ng-click="post(pagedata.aiset,'/aiset/setstatus/status=0&id='+pagedata.aiset.id)">停止机器人</a>
			</div>
			</div>
			</div>
	</div>
</div>

<div ng-include="sys_html('_footer')"></div>
<script>
scope.pagedata.upjifen2=function(){
	var yaonum=scope.pagedata.aiset.yaonum>0?scope.pagedata.aiset.yaonum:0;
	var addfee=scope.pagedata.aiset.addfee>0?scope.pagedata.aiset.addfee:0;
	var onefee=scope.pagedata.aiset.onefee>0?scope.pagedata.aiset.onefee:0;
	var baobei=scope.pagedata.aiset.baobei>0?scope.pagedata.aiset.baobei:1;	
	var fee=onefee;
	for(var i=1;i<yaonum;i++){
		onefee=onefee*1+addfee*1;
		fee=fee*1+onefee*1;
	}
	var jifen=0;
	if(scope.pagedata.cang.jian_xiaojinum>0){
		jifen +=scope.pagedata.cang.jian_xiaojinum*1*fee/100;
	}
	if(scope.pagedata.pluginset.ai_needji==1 && scope.pagedata.pluginset.ai_jinum>0){
		jifen +=scope.pagedata.pluginset.ai_jinum*1;
	}
	scope.pagedata.aiset.payfee=fee;
	scope.pagedata.aiset.payjifen=jifen
	scope.$evalAsync();
}
scope.pagedata.topost=function(){
	scope.confirm({
		'message':'确认要支付吗？',
		'success':function(){
			scope.post(scope.pagedata.aiset,'/aiset/post/');
		},
		'fail':function(){}
	});
}
</script>